//
//  TotalCityCollectionViewCell.m
//  PTravel
//
//  Created by dllo on 15/11/19.
//  Copyright © 2015年 李涵. All rights reserved.
//

#import "TotalCityCollectionViewCell.h"

@implementation TotalCityCollectionViewCell
- (void)dealloc
{
    [_cname release];
    [_ename release];
    [_describeLabel release];
    [_numLabel release];
    [_image release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changColor) name:@"night" object:nil];
        [self createSubViews];
    }
    return self;
}

- (void)changColor
{
    self.contentView.backgroundColor = CELLCOLOR;
}
- (void)createSubViews
{
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(5, 2, BOUNDS.size.width/2-20, (BOUNDS.size.height-64)/3-95)];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.cname = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width/2-50,self.image.frame.size.height/2-20,100,20)];
    self.numLabel.backgroundColor = [UIColor redColor];
    self.cname.font = [UIFont systemFontOfSize:17];
    self.cname.textAlignment = 1;
    [self.image addSubview:self.cname];
    [_cname release];
    
    
    self.ename = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width/2-50,self.image.frame.size.height/2,100,20)];
    self.ename.font = [UIFont systemFontOfSize:15];
    self.ename.textAlignment = 1;
    [self.image addSubview:self.ename];
    [_ename release];
    
    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.image.frame.origin.x, self.image.frame.origin.y+self.image.frame.size.height+5, self.contentView.frame.size.width, 30)];
    self.numLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.numLabel];
    [_numLabel release];
    
    
    
    self.describeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.numLabel.frame.origin.x, self.numLabel.frame.origin.y+self.numLabel.frame.size.height, self.contentView.frame.size.width-5, 40)];
    self.describeLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.describeLabel];
    [_describeLabel release];
    
   self.contentView.backgroundColor = CELLCOLOR;
}

- (void)setCity:(City *)city
{
    if (_city != city) {
        [_city release];
        _city = [city retain];
    }
    self.cname.text = city.catename;
    self.ename.text = city.catename_en;
    self.numLabel.text = city.beenstr;
    self.describeLabel.text = city.representative;
    self.describeLabel.numberOfLines = 0;
    NSURL *url = [NSURL URLWithString:city.photo];
    [self.image sd_setImageWithURL:url placeholderImage:IMAGE];
    self.numLabel.textColor = TEXTCOLOR;
    self.describeLabel.textColor = TEXTCOLOR;
}

@end
